package common.dataObjects
{
	import mx.collections.ArrayCollection;
	public class ProfileDO
	{
		public var groupingFields:Array;
		public var summaryFields:Array;
		public var source:String;
		public var columnAC:ArrayCollection;
		public var pageSize:int = 10;
		
		public function ProfileDO()
		{
		}
		
		public static function getProfile(list:XMLList):ProfileDO
		{
			for each(var profileXML:XML in list)
			{
				var profile:ProfileDO = new ProfileDO();
				var tempStr:String = null;
				
				tempStr = String(profileXML.@groupingFields);
				if (tempStr == null || tempStr.length < 1)
					profile.groupingFields = null;
				else
					profile.groupingFields = tempStr.split(",");
					
				tempStr = String(profileXML.@summaryFields);
				if (tempStr == null || tempStr.length < 1)
					profile.summaryFields = null;
				else
					profile.summaryFields = tempStr.split(",");
				profile.source = profileXML.@source;
				profile.columnAC = new ArrayCollection();
				
				tempStr = String(profileXML.@pageSize);
				if (tempStr == null || tempStr.length < 1)
					profile.pageSize = 10;
				else
					profile.pageSize = Number(tempStr);

				for each(var columnXML:XML in profileXML.column)
				{
					var column:ColumnDO = new ColumnDO();
					column.dataField = columnXML.@dataField;
					column.headerText = columnXML.@headerText;
					column.width = columnXML.@width;
					column.itemRenderer = columnXML.@itemRenderer;
					column.editable = columnXML.@editable;
					profile.columnAC.addItem(column);
				}
			}
			return profile;
		}
	}
}